package com.bw.mvvm_common.network;

import com.bw.mvvm_common.network.inteceptor.TokenInterceptor;

import okhttp3.OkHttpClient;
import retrofit2.Retrofit;
import retrofit2.adapter.rxjava2.RxJava2CallAdapterFactory;
import retrofit2.converter.gson.GsonConverterFactory;

/**
 * @author KK
 * @description:
 * @date :2021/10/13 15:52
 */
public class TokenImpl extends BaseImpl {
    Retrofit retrofit;
    @Override
    public Retrofit getRetrofit() {
        OkHttpClient.Builder builder = createOkHttpBuilder();
        builder.addInterceptor(new TokenInterceptor());
        Retrofit.Builder retrofitBuilder = new Retrofit.Builder();
        retrofitBuilder.baseUrl(Api.baseUrl);
        retrofitBuilder.client(builder.build());
        retrofitBuilder.addCallAdapterFactory(RxJava2CallAdapterFactory.create());
        retrofitBuilder.addConverterFactory(GsonConverterFactory.create());
        retrofit = retrofitBuilder.build();

        return retrofit;
    }
}
